# makefile for breemlib-dependant emulators

CONFIG ?= debug

debug_CFLAGS = -g
debug_LDFLAGS =

release_CFLAGS = -O3 -fomit-frame-pointer
release_LDFLAGS = -s

CFLAGS = -DLOGGER -I../breemlib -I. -g $(debug_CFLAGS)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -L../breemlib $(debug_LDFLAGS)
LIBS = -lbreemlib -lz -lSDL -lSDLmain

SOURCE += $(addprefix romset/,$(ROMSET)) $(addprefix machine/,$(MACHINE))

CC = gcc
CXX = g++
LD = g++
AR = ar

CSOURCE = $(filter %.c,$(SOURCE))
CXXSOURCE = $(filter %.cpp,$(SOURCE))

OBJECT = $(sort $(CSOURCE:.c=.o) $(CXXSOURCE:.cpp=.o))

OUTPUT = $(NAME)$(EXEEXT)

$(OUTPUT): $(OBJECT)
	$(LD) -o $@ $(LDFLAGS) $(OBJECT) $(LIBS)

all: version.h $(OUTPUT)

clean:
	rm -rf $(OUTPUT) $(OBJECT)

gdb: all
	gdb $(OUTPUT)

run: all
	$(OUTPUT) $(TESTROM)
